package com.hpxx.ylzswl.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hpxx.ylzswl.R;
import com.hpxx.ylzswl.bean.OrderListBean;
import com.hpxx.ylzswl.utils.ViewHolder;
import com.universal.frame.generalutils.GeneralUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/11/7.
 */

public class OrderSearchAdapter extends BaseAdapter{

    private Context context;
    private List<OrderListBean> list;

    public OrderSearchAdapter(Context context, List<OrderListBean> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public OrderListBean getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        OrderListBean bean = getItem(position);
        if(view == null){
            view = View.inflate(context, R.layout.item_order,null);
        }

        TextView tv_order_month = ViewHolder.get(view,R.id.tv_order_month);
        tv_order_month.setText(GeneralUtil.getHanZi2(bean.createMonth));

        TextView tv_order_day = ViewHolder.get(view,R.id.tv_order_day);
        tv_order_day.setText(bean.createDay+"日");

        TextView tv_order_xq = ViewHolder.get(view,R.id.tv_order_xq);
        tv_order_xq.setText(GeneralUtil.changeWeekToCN(bean.createWeek));

        TextView tv_order_hzname = ViewHolder.get(view,R.id.tv_order_hzname);
        tv_order_hzname.setText(bean.patientName);

        TextView tv_order_adess = ViewHolder.get(view,R.id.tv_order_adess);
        tv_order_adess.setText(bean.hospitalName);

        TextView tv_order_ysname = ViewHolder.get(view,R.id.tv_order_ysname);
        tv_order_ysname.setText("医生:"+bean.doctorRealname);

        TextView tv_order_data = ViewHolder.get(view,R.id.tv_order_data);
        tv_order_data.setText("时间:"+bean.create_time);



        ImageView iv_red = ViewHolder.get(view,R.id.iv_red);
        if("0".equals(bean.logisticRead)){
            iv_red.setVisibility(View.VISIBLE);
        }else {
            iv_red.setVisibility(View.INVISIBLE);
        }
        TextView tv_order_status = ViewHolder.get(view,R.id. tv_order_status);
        //2 代付款 3已付款 4已送样 5实验室检测中 6已完成 7已退款 8已取消
        if("0".equals(bean.orderStatus)){
            tv_order_status.setText("待接单");
        }else if ("1".equals(bean.orderStatus)){
            tv_order_status.setText("已接单");
        }
        else if ("2".equals(bean.orderStatus)){
            tv_order_status.setText("待付款");
        }
        else if("3".equals(bean.orderStatus)){
            tv_order_status.setText("已付款");
        }else if ("4".equals(bean.orderStatus)){
            tv_order_status.setText("已送样");
        }else if ("5".equals(bean.orderStatus)){
            tv_order_status.setText("检测中");
        }else if ("6".equals(bean.orderStatus)){
            tv_order_status.setText("已完成");
        }else if ("7".equals(bean.orderStatus)){
            tv_order_status.setText("已退款");
        }else if ("8".equals(bean.orderStatus)){
            tv_order_status.setText("已取消");
        }

        return view;
    }
}
